package structural.facade.custom.devices;

import java.util.Random;

/**
 * 温度计
 */
public class Thermometer {

    private int temperature;

    public Thermometer() {
        temperature = showTemperature();
    }

    /**
     * 显示当前温度
     * @return
     */
    public int showTemperature() {
        this.temperature = new Random().nextInt(80) - 40;
        System.out.println("当前温度: " + temperature);
        return this.temperature;
    }

    /**
     * 冷
     * @return
     */
    public boolean isCold() {
        return (this.temperature < 10);
    }

    /**
     * 热
     * @return
     */
    public boolean isHot() {
        return (this.temperature > 28);
    }

    /**
     * 适宜
     * @return
     */
    public boolean isSuitable() {
        return (this.temperature >= 10 && this.temperature <= 28);

    }

    public static void main(String[] args) {
        Thermometer thermometer = new Thermometer();
        for (int i = 0; i < 100; i++) {
            System.out.println(thermometer.showTemperature());
        }
    }
}
